﻿using AutoResetEventTest.ISagaStorages;
using Microsoft.Extensions.DependencyInjection;
using Stee.CAP8.MessageBus.Sagas.Core.Ioc;
using System;
using System.Threading;
using System.Threading.Tasks;

namespace Stee.CAP8.MessageBus.Sagas.Core.Sagas.SagaData
{
    class Program
    {
        static void Main(string[] args)
        {
            var id = "12";
            
            var services = new ServiceCollection();
            
            services.AddSingleton<ISagaStorage, InMemorySagaStorage>();
            SagaContainer.ServiceProvider = services.BuildServiceProvider();
          

            Task.Run(() => {

                OrderSagaData sagaData = new OrderSagaData(id)
                {
                    OrderCreated = true
                };
                sagaData.OrderPaymented = true;

            });
            Thread.CurrentThread.Join(2100);
            Task.Run(() => {


                var sagaData1 = new OrderSagaData(id);

            });

            //sagaData.LoadData();
            Console.Read();

        }
    }
}
